body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #E5DDD5; 
    margin: 0;
    padding: 0;
    min-height: 100vh; 
    box-sizing: border-box;
    position: relative; 
    overflow-x: hidden; 
}

body::before {
    content: "";
    position: fixed; 
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('/EAC4C99E-0A61-43A6-BA3A-F65881A1.webp');
    /* Default size for portrait view, ensuring it's large but fits the width */
    background-size: 95vw; 
    background-position: center center; 
    background-repeat: no-repeat; 
    opacity: 0.2; 
    z-index: -1; 
}

h1 {
    color: #fff;
    background-color: #075E54; 
    width: 100%;
    text-align: center;
    padding: 15px 0;
    margin: 0; 
    font-size: 1.2em; 
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    position: sticky;
    top: 0;
    z-index: 2; 
}

#chat-container {
    background-color: transparent; 
    border-radius: 0; 
    box-shadow: none; 
    width: 100%;
    max-width: 800px; 
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden; 
    margin-bottom: 0; 
    box-sizing: border-box;
    z-index: 1; 
    position: relative; 
}

#chat-output {
    flex-grow: 1;
    padding: 10px 10px 15px 10px;
    overflow-y: auto; 
    border-bottom: none;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

#chat-output::-webkit-scrollbar {
  width: 6px;
}
#chat-output::-webkit-scrollbar-track {
  background: transparent;
}
#chat-output::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.message {
    padding: 7px 10px;
    border-radius: 7px;
    max-width: 80%; 
    line-height: 1.4;
    box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
    word-wrap: break-word; 
    position: relative; 
    margin-bottom: 5px;
    font-size: 0.95em;
    display: inline-block; 
}

.message.user {
    background-color: #DCF8C6; 
    color: #000;
    align-self: flex-end; 
    margin-left: auto; 
    border-bottom-right-radius: 2px; 
}

.message.ai {
    background-color: #FFFFFF; 
    color: #333;
    align-self: flex-start; 
    margin-right: auto; 
    border-bottom-left-radius: 2px; 
}

.message.ai.thinking-indicator {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    min-width: 40px; 
}

.message.ai.thinking-indicator span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: #888;
    border-radius: 50%;
    margin: 0 2px;
    animation: thinking-dots 1.4s infinite ease-in-out both;
}

.message.ai.thinking-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.message.ai.thinking-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

.message.ai.thinking-indicator span:nth-child(3) {
     animation-delay: 0s; 
}

@keyframes thinking-dots {
  0%, 80%, 100% {
    transform: scale(0);
  } 40% {
    transform: scale(1.0);
  }
}

#input-area {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-top: none; 
    background-color: #f0f0f0; 
    position: sticky; 
    bottom: 0;
    z-index: 1; 
}

#user-input {
    flex-grow: 1;
    padding: 10px 15px;
    border: none;
    border-radius: 20px; 
    margin-right: 8px;
    font-size: 1em;
    background-color: #fff;
    box-shadow: inset 0 1px 1px rgba(0,0,0,0.06);
}

#user-input::placeholder {
    color: #999;
}

#user-input:focus {
    outline: none;
    box-shadow: inset 0 1px 1px rgba(0,0,0,0.06); 
}

#send-button {
    padding: 0;
    background-color: #128C7E; 
    color: white;
    border: none;
    border-radius: 50%; 
    cursor: pointer;
    font-size: 1.4em;
    width: 44px; 
    height: 44px; 
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s;
    line-height: 1; 
    flex-shrink: 0; 
}

#send-button:hover {
    background-color: #075E54; 
}

/* --- Media Queries for Responsiveness --- */

/* Tablet and Smaller Desktops */
@media (max-width: 800px) {
    #chat-container {
        max-width: 100%; 
    }
    .message {
        max-width: 85%; 
    }
}

/* Mobile Devices */
@media (max-width: 600px) {
    h1 {
        font-size: 1.1em; 
        padding: 12px 0;
    }

    #chat-output {
        padding: 8px 8px 12px 8px; 
    }

    .message {
        font-size: 0.9em; 
        padding: 6px 9px;
        max-width: 90%; 
    }

    #input-area {
        padding: 6px 8px; 
    }

    #user-input {
        padding: 9px 12px; 
        font-size: 0.95em;
    }

    #send-button {
        width: 40px; 
        height: 40px;
        font-size: 1.3em;
    }
}

/* Adjust background image size for landscape orientation to ensure it fits the height without cropping */
@media (orientation: landscape) {
    body::before {
        background-size: 80vh;
    }
}